package portal.manager.data;

import java.beans.BeanDescriptor;
import java.beans.PropertyDescriptor;
import java.sql.Types;

import org.bsc.bean.AbstractManagedBeanInfo;
import org.bsc.bean.BeanDescriptorEntity;
import org.bsc.bean.PropertyDescriptorField;
import org.bsc.bean.PropertyDescriptorPK;
import org.bsc.bean.adapters.CharBooleanAdapter;

import portal.manager.data.Template.Variable;

/**
 * 
 * @author Sorrentino
 *
 */
public class TemplateVariableBeanInfo extends AbstractManagedBeanInfo<Template.Variable> {

	
	protected TemplateVariableBeanInfo(Class<? extends Variable> beanClass) {
		super(beanClass);
	}

	public TemplateVariableBeanInfo() {
		super(Template.Variable.class);
	}

	public BeanDescriptor getBeanDescriptor() {
        return new BeanDescriptorEntity(getBeanClass(), "TEMPLATE_VARIABLE");
	}

	public PropertyDescriptor[] getPropertyDescriptors() {
        try {
            
            return new PropertyDescriptor[] {
                new PropertyDescriptorPK( "id", getBeanClass(), "getId", "setId")
            		.setSQLType(Types.VARCHAR)
                	.setSize(128),
                new PropertyDescriptorField( "templateId", getBeanClass(), "getTemplateId", "setTemplateId")
                	.setSize(128),
                    new PropertyDescriptorField( "name", getBeanClass(), "getName", "setName")
                	.setSize(20),	
                new PropertyDescriptorField( "block", getBeanClass(), "isBlock", "setBlock")
                	.setSQLType(Types.CHAR)
                	.setSize(1)
                	.setAdapter( new CharBooleanAdapter()),
                new PropertyDescriptorField( "codeModule", getBeanClass(), "isCodeModule", "setCodeModule")
                	.setSQLType(Types.CHAR)
                	.setSize(1)
                	.setAdapter( new CharBooleanAdapter())
                	
            };
            
        }
        catch( Exception ex ) {
            throw new IllegalStateException(ex);
        } 
	}

}
